#ifndef _UBT_STATE_TASK_ACTION_H_
#define _UBT_STATE_TASK_ACTION_H_
#include "ubt_state_types.h"
#include "ubt_state_api.h"

namespace ubt_state
{

class CTaskAction: public ITask
{
  public:
    static int ClassInit();
    static void ClassCleanup();
    static ITask *CreateTask(ITaskCb *pTaskCb, std::string taskId, Action *pAction, int index, int reportIndex);
    CTaskAction(ITaskCb *pTaskCb, std::string taskId, Action *pAction, int index, int reportIndex);
    ~CTaskAction();

    virtual bool Start();
    virtual void Pause();
    virtual void Continue();
    virtual void Stop(int reason);

    virtual void OnTimer();
    virtual void OnMsg(int msgType, void *pvMsg);

    virtual ubt_task_type GetType();
    virtual ubt_task_state GetState();
    virtual ubt_task_stage GetStage();
    virtual std::string GetActionType();
    virtual void GetIndex(int& index, int& reportIndex);
    virtual void GetStopInfo(int& stopReason, std::string& stopReasonDesc);
    virtual void GetLogs(std::vector<TaskLogItem>& logs);


    void Action_Status_Callback(const std_msgs::msg::String::SharedPtr msg);
  private:
    void _SetState(ubt_task_state newState, int reason, std::string reasonStr);
    ITaskCb *_pTaskCb;
    std::string _taskId;
    Action _action;
    int _index;
    int _reportIndex;
    ubt_task_state _state;

    int _flag;//rpc called
    int _stopReason;
    std::string _stopReasonDesc;
};

}
#endif

